import { useEffect, useRef } from "react";
import React from "react";

// 组件实例只有类组件
class Test extends React.Component {
  getName = () => {
    return 'this is child'
  }
  render() {
    return (
      <div>
        我是一个类组件
      </div>
    )
  }
}

function App () {
  const testRef = useRef(null)
  const h1Ref = useRef(null)

  useEffect(() => {
    console.log(testRef);
    console.log(testRef.current);
    console.log(testRef.current.getName());
    console.log(h1Ref);
    console.log(h1Ref.current);
  }, [])
  return (
    <div>
      <h1 ref={ h1Ref }>this is h1</h1>
      <Test ref={ testRef }></Test>
    </div>
  )
}

export default App;
